﻿import QtQuick 2.4


Item
{
    Connections{
        target: app
        onSignalAQITimeChanged:{
            var time = timestr;
            //添加了判断
            if(time.length >0)
            {
                var v = time.split(" ");
                mdata.text = v[0];
                mtime.text = v[1].substr(0,5);
            }
        }
    }

    property string timeValue: ""
    width: 494
    implicitHeight:backGound.height +4 +upItem.height
    Item {
        id: downItem
        implicitHeight:backGound.height
        implicitWidth: backGound.width

        Image {
            id: backGound
              width: 494
            source: "./切图/时间面板/底子.png"
            MouseArea
            {
                anchors.fill: parent
                onDoubleClicked:
                {
                    colseAppRan()
                    upItem.visible = true
                }
            }
        }

        Text {
            id: timeUpText
            text: "更新时间"
            font.family: "微软雅黑"
            font.pixelSize: 20
            anchors.left: parent.left
            anchors.leftMargin: 164
            anchors.top: parent.top
            anchors.topMargin: 18
            color: "white"
        }

        Text{
            id:mdata
            text:new Date().toLocaleDateString(Qt.locale("de_DE"),"yyyy-MM-dd")

            color:"white"
            anchors.left:parent.left
            anchors.top: timeUpText.bottom
            anchors.topMargin: 6
            anchors.leftMargin:74
            font.family: "微软雅黑"
            font.pixelSize: 28
        }
        Text{
            id:mtime
            text:new Date().toLocaleTimeString(Qt.locale("de_DE"),"hh:mm")
            color:"white"
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 18
            anchors.left:timeUpText.right
            anchors.leftMargin: 72
            font.family: "微软雅黑"
            font.pixelSize: 52

        }

    }

    Item
    {
        id:upItem
        implicitHeight:upItemGound.height
        implicitWidth: upItemGound.width
        anchors.top:  downItem.bottom
        anchors.topMargin: 4
        transform: Scale { origin.x: 0; origin.y: 0; xScale: root.x_enl-0.3;yScale: root.y_enl-0.3}
        visible: false
        Image {
            id: upItemGound
               width: 412
            source: "./切图/时间面板/底子01.png"

        }
        Image
        {
            id: upItemClose
            source: "./切图/时间面板/关闭.png"
            anchors.right: parent.right
            anchors.rightMargin: 12
            anchors.top: parent.top
            anchors.topMargin: 13
            MouseArea
            {
                anchors.fill: parent
                onPressed: upItemClose.source = "./切图/时间面板/关闭触碰.png"
                onReleased: upItemClose.source = "./切图/时间面板/关闭.png"
                onClicked:
                {
                    upItem.visible = false
                }
            }
        }
        Item
        {
            width: parent.width
            height: parent.height - 35
            anchors.bottom: parent.bottom

            Row
            {
                id:timeRow
                anchors.left: parent.left
                anchors.top: parent.top
                anchors.leftMargin: 70
                anchors.topMargin: 16
                spacing: 5
                Image {
                    id: yearImage
                    source: "./切图/时间面板/年.png"
                    TextInput
                    {
                        id:yearInput
                        height:yearImage.height
                        width:yearImage.width
                        anchors.top:yearImage.top
                        anchors.topMargin:4
                        anchors.left:yearImage.left
                        anchors.leftMargin:6
                        text:new Date().toLocaleDateString(Qt.locale("de_DE"),"yyyy")
                        font.pixelSize: 21
                        color:"white"
                        font.family: "黑体"
                        focus: upItem.visible ? true :false
                        inputMask: "0000"
                        KeyNavigation.tab: monthInput
                    }
                }
                Text
                {
                    id: yearText
                    text:"年"
                    font.pixelSize: 20
                    color:"white"
                    font.family: "微软雅黑"
                }
                Image {
                    id: monthImage
                    source: "./切图/时间面板/月.png"
                    TextInput
                    {
                        id:monthInput
                        height:monthImage.height
                        width:monthImage.width
                        anchors.top:monthImage.top
                        anchors.topMargin:4
                        anchors.left:monthImage.left
                        anchors.leftMargin:8
                        text:new Date().toLocaleDateString(Qt.locale("de_DE"),"MM")
                        font.pixelSize: 21
                        color:"white"
                        font.family: "黑体"

                        KeyNavigation.tab: dayInput
                        validator: RegExpValidator
                        {
                        regExp:new RegExp(" ^[0]|[1][0-2]|[1-9] ")
                        //                        regExp:new RegExp(" ^[2-9]|[1][0-2]|[0][1-9] ")
                    }
                }
            }
            Text
            {
                id: monthText
                text:"月"
                font.pixelSize: 20
                color:"white"
                font.family: "微软雅黑"
            }

            Image {
                id: dayImage
                source: "./切图/时间面板/日.png"
                TextInput
                {
                    id:dayInput
                    height:dayImage.height
                    width:dayImage.width
                    anchors.top:dayImage.top
                    anchors.topMargin:4
                    anchors.left:dayImage.left
                    anchors.leftMargin:8
                    text:new Date().toLocaleDateString(Qt.locale("de_DE"),"dd")
                    font.pixelSize: 21
                    color:"white"
                    font.family: "黑体"
                    KeyNavigation.tab: hourInput
                    validator: RegExpValidator
                    {
                    regExp:new RegExp(" ^[0]|[1][0-9]|[1-9]|[2][0-9]|[3][0-1]")
                    //                        regExp:new RegExp(" ^[2-9]|[1][0-2]|[0][1-9] ")
                }
            }
        }
        Text
        {
            id: dayText
            text:"日"
            font.pixelSize: 20
            color:"white"
            font.family: "微软雅黑"
        }


        Image {
            id: hourImage
            source: "./切图/时间面板/时.png"
            TextInput
            {
                id:hourInput
                height:hourImage.height
                width:hourImage.width
                anchors.top:hourImage.top
                anchors.topMargin:4
                anchors.left:hourImage.left
                anchors.leftMargin:8
                text:new Date().toLocaleTimeString(Qt.locale("de_DE"),"hh")
                font.pixelSize: 21
                color:"white"
                font.family: "黑体"
                //                        focus: true
                KeyNavigation.tab:determineImage
                maximumLength:2
                validator: IntValidator{bottom: 01;top:24}
            }
        }
        Text
        {
            id: hourText
            text:"时"
            font.pixelSize: 20
            color:"white"
            font.family: "微软雅黑"
        }
    }

    Row
    {

        anchors.left: parent.left
        anchors.top: timeRow.bottom
        anchors.leftMargin: 100
        anchors.topMargin: 10
        spacing: 40
        Image
        {
            id: determineImage
            source: "./切图/时间面板/确定.png"
            KeyNavigation.tab: cancelImage
            onActiveFocusChanged:
            {
                if(focus === true)
                {
                    determineImage.source = "./切图/时间面板/确定点击.png"

                }else
                {
                    determineImage.source = "./切图/时间面板/确定.png"
                }

            }

            MouseArea
            {
                id:determineArea
                anchors.fill: parent
                hoverEnabled: true

                onEntered:
                {
                    determineImage.source = "./切图/时间面板/确定点击.png"
                }
                onExited:
                {


                    determineImage.source = "./切图/时间面板/确定.png"
                }
                onClicked:
                {
                    if(monthInput.text.length ===1)
                    {
                        monthInput.text ="0"  +monthInput.text
                    }
                    if(dayInput.text.length ===1)
                    {
                        dayInput.text ="0"  +dayInput.text
                    }
                    if(hourInput.text.length ===1)
                    {
                        hourInput.text ="0"  +hourInput.text
                    }

                    timeValue = yearInput.text+ "-" + monthInput.text + "-" + dayInput.text + " " + hourInput.text +":00:00"
                    //emit: openSliverTime()
                    //临时信号 暂用openSliverTime信号
                    mainApp.slotTime_changed(timeValue)
//                    emit: openSliverTime()

                    if(monthInput.text.length!=0|dayInput.text.length!=0|hourInput.text.length!=0|yearInput.text.length!=0)
                    {
                        timeUpText.text = "查询时间" //更新与
                        mdata.text = yearInput.text+ "-" + monthInput.text + "-" + dayInput.text
                        mtime.text = hourInput.text +":00"
                    }else
                    {

                    }
                }
            }
        }
        Image
        {
            id: cancelImage
            source: "./切图/时间面板/取消.png"
            KeyNavigation.tab: yearInput

            onActiveFocusChanged:
            {
                if(focus === true)
                {
                    cancelImage.source = "./切图/时间面板/取消点击.png"
                }else
                {
                    cancelImage.source = "./切图/时间面板/取消.png"
                }

            }
            MouseArea
            {
                id:cancelArea
                anchors.fill: parent
                hoverEnabled: true
                onEntered:
                {
                    cancelImage.source = "./切图/时间面板/取消点击.png"
                }
                onExited:
                {

                    cancelImage.source = "./切图/时间面板/取消.png"

                }
                onClicked:
                {
                    upItem.visible=false
                }
            }
        }

    }
}
}
                function colseAppRan()
                {
                    raning.visible = false
                    detaSh.visible = false
//                    menu.replaceSite();
                }
}
